<script>
	import config from './config'
	import store from '@/store'
	import {
		getToken
	} from '@/utils/auth'

	export default {
		onLaunch: function() {
			this.initApp()
		},
		methods: {
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()

				// 获取设备ID
				this.getDeviceId()
				this.getDeviceInfo()
			},
			initConfig() {
				this.globalData.config = config
			},
			//获取客户端ID
			getDeviceId() {
				//获取客户端ID和版本号
				let deviceId = '';
				// #ifdef APP-PLUS
				// 苹果系统
				plus.device.getInfo({
					success: function(e) {
						deviceId = e.uuid;
						uni.setStorageSync('deviceId', deviceId);
					},
					fail: function(e) {
						console.log(e);
					}
				});
				// 安卓系统
				plus.device.getAAID({
					success: function(e) {
						deviceId = e.aaid;
						uni.setStorageSync('deviceId', deviceId);
					},
					fail: function(e) {
						console.log(e);
					}
				});
				//老版本、安卓模拟器
				if (deviceId == '') {
					deviceId = plus.device.uuid;
					uni.setStorageSync('deviceId', deviceId);
				}
				// #endif

				// #ifdef H5
				uni.setStorageSync('deviceId', "888888");
				// #endif
				return deviceId;
			},
			getDeviceInfo() {

				// #ifdef APP-PLUS
				uni.getSystemInfo({
					success(res) {
						uni.setStorageSync("deviceType", res.platform)
					}
				})
				// #endif

				// #ifdef H5
				uni.setStorageSync("deviceType", "android")
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/scss/index.scss'
</style>